package maf;


import static org.junit.Assert.assertTrue;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.events.TurnEndedEvent;
import robocode.control.snapshot.IBulletSnapshot;
import robocode.control.testing.RobotTestBed;

/**
 * Tests that CompetitiveRobot fires off shots when an enemy is scanned.
 * @author Michael Fujimoto
 *
 */

public class TestCompRobotScannedFire extends RobotTestBed {
  /* True if any bullets were fired in a round, any bullet will be
   * CompetitiveRobot's if challenging SittingDuck
   */
  boolean bulletsFired = false;
  @Override
  public String getRobotNames() {
    return "sample.SittingDuck,maf.CompetitiveRobot";
  }

  /**
   * This test runs for 1 round.
   * @return The number of rounds. 
   */
  @Override
  public int getNumRounds() {
    return 10;
  }

  /**
   * After each turn, check to see if we're at a corner.  If so, set the corresponding flag.
   * @param event Info about the current state of the battle.
   */
  @Override 
  public void onTurnEnded(TurnEndedEvent event) {
    IBulletSnapshot[] allBullets = event.getTurnSnapshot().getBullets();
    if (allBullets != null) {
      bulletsFired = true;
    }

  }


  /**
   * After the battle, check to see that CompetitiveRobot fired bullets.
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    assertTrue("Check Bullets Fired", bulletsFired);
  }
}
